#Political science scholarship on the Middle East: A view from the journals
#Melani Cammett , Harvard University and Isabel Kendall, Harvard University

#Note: All data analyzed for this paper originally comes from the "MENA Trends 2019 Update" dataset, in order to facilitate creating figures in R, some data was first summerized in Excel using the Pivot Table function and then imported as a seterate dataset

#Loading needed packages:
library(ggplot2)
library(ggpubr)

#Loading the requisite datasets and formatting select variables:
finaltrends <- read.csv("MENA Trends 2019 Update.csv")
percentagemena <- read.csv("Total Articles and MENA.csv")
menatotal <- read.csv("Total Articles and MENA2.csv")
topicsfinal <- read.csv("Topics over time final.csv")
topicstotal <- read.csv("Topics Total.csv")
methodstotal <- read.csv("Methods Total.csv")
methodsovertime <- read.csv("Methods Over Time.csv")
methodstotalsimple <- read.csv("Methods Total Simple.csv")
methodsovertimesimple <- read.csv("Methods Over Time Simple.csv")
gender.methods <- read.csv("GenderXMethods.csv")
genderpercent <- read.csv("Percent woman of all authors by method.csv")
journalsharefinal <- read.csv("Journal Coverage Final.csv")
journalyear <- read.csv("Journal Year Final.csv")

finaltrends$Primary.Method <- as.factor(finaltrends$Primary.Method)
finaltrends$Primary.Topics <- as.factor(finaltrends$Primary.Topics)
finaltrends$Topic..2. <- as.factor(finaltrends$Topic..2.)
finaltrends$Method..2. <- as.factor(finaltrends$Method..2.)
menatotal$type <- as.factor(menatotal$type)

#Figure 1: The evolution of total articles and MENA-focused articles in political science journals, 2000-2019
#Create plot using ggplot and a dataset created in Excel using the Pivot Table function
ggplot(menatotal, aes(x = year, y = number)) + 
  geom_line(aes(linetype = type)) +  
  scale_linetype_manual(values=c(2, 1))+
  labs(title="Articles Published Over Time", 
       x="Year", y = "Number of Articles") +
  xlim(2000,2020) + ylim(0,700) +
  theme_light() +
  theme(legend.title = element_blank(), legend.position="bottom")

#Figures 2a-2d: The evolution of selected topics in MENA-focused scholarship in political science journals, 2000-2019
#Create subsets for each topic of interest using a dataset created in Excel using the Pivot Table function
topicyear1 <- subset(topicsfinal, Topic == 1)
topicyear3 <- subset(topicsfinal, Topic == 3)
topicyear9 <- subset(topicsfinal, Topic == 9)
topicyear11 <- subset(topicsfinal, Topic == 11)

#Create indivdual plots for each topic
t1 <- ggplot(topicyear1, aes(x = Year, y = Articles)) + 
  geom_line() +  
  labs(x="Year", y = "Articles", title = "4c: Regimes") +
  ylim(0,9) +
  theme_light()
t3 <- ggplot(topicyear3, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,9) +
  labs(x="Year", y = "Articles", title = "4a: Social Mobilization") +
  theme_light()
t9 <- ggplot(topicyear9, aes(x = Year, y = Articles)) + 
  geom_line() +  
  labs(x="Year", y = "Articles", title = "4b: Conflict") +
  ylim(0,9) +
  theme_light()
t11 <- ggplot(topicyear11, aes(x = Year, y = Articles)) + 
  geom_line() +  
  labs(x="Year", y = "Articles", title = "4d: Elections and Voting Behavior") +
  ylim(0,9) +
  theme_light()

#Arrange indivdual plots into one figure and annotate
tlineselected <- ggarrange(t3, t9, t1, t11,
                           common.legend = TRUE, legend = "none",
                           ncol = 2, nrow = 2)
annotate_figure(tlineselected,
                top = text_grob("Selected Topics Over Time", color = "black", face = "bold", size = 14))

#Figure 3: Research methods employed in MENA-focused scholarship in political science journals, 2000-2019
#Create pie chart using a dataset created in Excel using the Pivot Table function
ggplot(methodstotalsimple, aes(x="", y=Articles, fill=Method.Name)) + 
  geom_bar(stat="identity", width=1) + 
  coord_polar("y", start=0) + 
  geom_text(aes(label = paste0(round(100*(Articles/224)), "%")), position = position_stack(vjust = 0.5), color = "white") +
  scale_fill_grey(start = 0.2, end = 0.7) +
  labs(x = NULL, y = NULL, fill = NULL, title = "Primary Method - Article Share") +
  theme_classic() + theme(axis.line = element_blank(),
                          axis.text = element_blank(),
                          axis.ticks = element_blank(),
                          plot.title = element_text(hjust = 0.5, vjust = -5))

#Figures 4a-d: The evolution of research methods employed in MENA-focused scholarship in political science journals, 2000-2019
#Create subsets for each method using a dataset created in Excel using the Pivot Table function
methodsimple.ft <- subset(methodsovertimesimple, Method.Name == "Formal Theory")
methodsimple.stat <- subset(methodsovertimesimple, Method.Name == "Statistical")
methodsimple.exp <- subset(methodsovertimesimple, Method.Name == "Experiments")
methodsimple.qual <- subset(methodsovertimesimple, Method.Name == "Qualitative")

#Create indivdual plots for each method
mft <- ggplot(methodsimple.ft, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,15) +
  labs(x="Year", y = "Articles", title = "4a: Formal Theory") +
  theme_light()
mstat <- ggplot(methodsimple.stat, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,15) +
  labs(x="Year", y = "Articles", title = "4c: Statistical") +
  theme_light()
mexp <- ggplot(methodsimple.exp, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,15) +
  labs(x="Year", y = "Articles", title = "4d: Experiments") +
  theme_light()
mqual <- ggplot(methodsimple.qual, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,15) +
  labs(x="Year", y = "Articles", title = "4b: Qualitative") +
  theme_light()

#Arrange indivdual plots into one figure and annotate
mslinetotal <- ggarrange(mft, mqual, mstat, mexp,
                         common.legend = TRUE, legend = "none",
                         ncol = 2, nrow = 2)
annotate_figure(mslinetotal,
                top = text_grob("Methods Over Time", color = "black", face = "bold", size = 14))

#Figure 5: Author composition of MENA-focused articles in political science journals, 2000-2019
#Create plot using ggplot and a dataset created in Excel using the Pivot Table function
gender.total <- subset(gender.methods, Method == "Total")
ggplot(gender.total, aes(x = Composition, y = Articles)) + 
  geom_bar(stat="identity", fill = "grey 44") +
  labs(title="Author Composition", 
       x="", y = "Number of Articles") +
  ylim(0,70) + 
  theme(axis.text.x = element_text(angle = 90, hjust = 1))+
  theme_light()

#Figure 6: Author composition of MENA-focused articles in political science journals by primary method, 2000-2019
#Create plot using ggplot and a dataset created in Excel using the Pivot Table function
gender.methods <- subset(gender.methods, Method != "Total")
ggplot(gender.methods , aes(fill = Composition, x = Method, y = Articles)) + 
  geom_bar(stat="identity", position = "dodge") +
  labs(title="Author Composition by Method", 
       x="", y = "Number of Articles") +
  scale_fill_grey(start = 0.1, end = 0.7) +
  ylim(0,45) + 
  theme(axis.text.x = element_text(angle = 90, hjust = 1))+
  theme_light()

#Figures from the online appendix:
#Figure A1: The evolution of the percentage of MENA-focused articles in political science journals, 2000-2019
#Create plot using ggplot and a dataset created in Excel using the Pivot Table function
ggplot(percentagemena, aes(x = year, y = percentage, label = percentagelabel)) + 
  geom_line() + 
  geom_point() +  
  labs(title="Percentage of Articles Published on the MENA Over Time", x="Year", y = "Percentage") + 
  xlim(2000,2020) + ylim(0,100) + 
  theme_light()

#Figure A2: Journal share of MENA-focused articles, 2000-2019
#Create pie chart using a dataset created in Excel using the Pivot Table function
jsum = sum(journalsharefinal$Articles)
ggplot(journalsharefinal, aes(x="", y=Articles, fill=Journal)) + 
  geom_bar(stat="identity", width=1, color = "white") + 
  coord_polar("y", start=0) + 
  geom_text(aes(label = paste0(round(100*(Articles/jsum)), "%")), position = position_stack(vjust = 0.5), color = "black") +
  labs(x = NULL, y = NULL, fill = NULL, title = "Journal Share of MENA Focused Articles") +
  theme_classic() + theme(axis.line = element_blank(),
                          axis.text = element_blank(),
                          axis.ticks = element_blank(),
                          plot.title = element_text(hjust = 0.5, vjust = -5))

#Figures A3a-A3m: The evolution of MENA-focused articles over time in political science journals, 2000-2019
#Create subsets for each journal using a dataset created in Excel using the Pivot Table function
ajps <- subset(journalyear, Journal == "American Journal of Political Science")
arps <- subset(journalyear, Journal == "Annual Review of Political Science")
bjps <- subset(journalyear, Journal == "British Journal of Political Science")
cps <- subset(journalyear, Journal == "Comparative Political Studies")
cp <- subset(journalyear, Journal == "Comparative Politics")
io <- subset(journalyear, Journal == "International Organization")
isq <- subset(journalyear, Journal == "International Studies Quarterly")
pp <- subset(journalyear, Journal == "Perspectives on Politics")
prq <- subset(journalyear, Journal == "Political Research Quarterly")
qjps <- subset(journalyear, Journal == "Quarterly Journal of Political Science")
apsr <- subset(journalyear, Journal == "The American Political Science Review")
jop <- subset(journalyear, Journal == "The Journal of Politics")
wp <- subset(journalyear, Journal == "World Politics")

#Create indivdual plots for each journal
g.ajps <- ggplot(ajps, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,7) +
  labs(x="Year", y = "Articles", title = "A3a: American Journal of Political Science") +
  theme_light()
g.arps <- ggplot(arps, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,7) +
  labs(x="Year", y = "Articles", title = "A3b: Annual Review of Political Science") +
  theme_light()
g.bjps <- ggplot(bjps, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,7) +
  labs(x="Year", y = "Articles", title = "A3c: British Journal of Political Science") +
  theme_light()
g.cps <- ggplot(cps, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,7) +
  labs(x="Year", y = "Articles", title = "A3d: Comparative Political Studies") +
  theme_light()
g.cp <- ggplot(cp, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,7) +
  labs(x="Year", y = "Articles", title = "A3e: Comparative Politics") +
  theme_light()
g.io <- ggplot(io, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,7) +
  labs(x="Year", y = "Articles", title = "A3f: International Organization") +
  theme_light()
g.isq <- ggplot(isq, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,7) +
  labs(x="Year", y = "Articles", title = "A3g: International Studies Quarterly") +
  theme_light()
g.pp <- ggplot(pp, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,7) +
  labs(x="Year", y = "Articles", title = "A3h: Perspectives on Politics") +
  theme_light()
g.prq <- ggplot(prq, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,7) +
  labs(x="Year", y = "Articles", title = "A3i: Political Research Quarterly") +
  theme_light()
g.qjps <- ggplot(qjps, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,7) +
  labs(x="Year", y = "Articles", title = "A3j: Quarterly Journal of Political Science") +
  theme_light()
g.apsr <- ggplot(apsr, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,7) +
  labs(x="Year", y = "Articles", title = "A3k: The American Political Science Review") +
  theme_light()
g.jop <- ggplot(jop, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,7) +
  labs(x="Year", y = "Articles", title = "A3l: The Journal of Politics") +
  theme_light()
g.wp <- ggplot(wp, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,7) +
  labs(x="Year", y = "Articles", title = "A3m: World Politics") +
  theme_light()

#Arrange indivdual plots into one figure and annotate
jlinetotal <- ggarrange(g.ajps, g.arps, g.bjps, g.cps, g.cp, g.io, g.isq, g.pp, g.prq, g.qjps, g.apsr, g.jop, g.wp,
                        common.legend = TRUE, legend = "none",
                        ncol = 2, nrow = 7)
annotate_figure(jlinetotal,
                top = text_grob("Journal Publications of MENA-Focused Articles Over Time", color = "black", face = "bold", size = 14))

#Figures A4a-A4k: Topics in MENA-focused scholarship in political science journals, 2000-2019
#Create subsets for each topic using a dataset created in Excel using the Pivot Table function
topicyear1 <- subset(topicsfinal, Topic == 1)
topicyear2 <- subset(topicsfinal, Topic == 2)
topicyear3 <- subset(topicsfinal, Topic == 3)
topicyear4 <- subset(topicsfinal, Topic == 4)
topicyear5 <- subset(topicsfinal, Topic == 5)
topicyear6 <- subset(topicsfinal, Topic == 6)
topicyear7 <- subset(topicsfinal, Topic == 7)
topicyear8 <- subset(topicsfinal, Topic == 8)
topicyear9 <- subset(topicsfinal, Topic == 9)
topicyear10 <- subset(topicsfinal, Topic == 10)
topicyear11 <- subset(topicsfinal, Topic == 11)
topicyear12 <- subset(topicsfinal, Topic == 12)

#Create indivdual plots for each topic
t1 <- ggplot(topicyear1, aes(x = Year, y = Articles)) + 
  geom_line() +  
  labs(x="Year", y = "Articles", title = "4c: Regimes") +
  ylim(0,9) +
  theme_light()
t2 <- ggplot(topicyear2, aes(x = Year, y = Articles)) + 
  geom_line() +  
  labs(x="Year", y = "Articles", title = "A4c: Religion and Politics") +
  ylim(0,9) +
  theme_light()
t3 <- ggplot(topicyear3, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,9) +
  labs(x="Year", y = "Articles", title = "4a: Social Mobilization") +
  theme_light()
t4 <- ggplot(topicyear4, aes(x = Year, y = Articles)) + 
  geom_line() +  
  labs(x="Year", y = "Articles", title = "A4g: Gender") +
  ylim(0,9) +
  theme_light()
t5 <- ggplot(topicyear5, aes(x = Year, y = Articles)) + 
  geom_line() +  
  labs(x="Year", y = "Articles", title = "A4e: Political Economy and Development") +
  ylim(0,9) +
  theme_light()
t6 <- ggplot(topicyear6, aes(x = Year, y = Articles)) + 
  geom_line() +  
  labs(x="Year", y = "Articles", title = "A4f: Patronage and Clientelism") +
  ylim(0,9) +
  theme_light()
t7 <- ggplot(topicyear7, aes(x = Year, y = Articles)) + 
  geom_line() +  
  labs(x="Year", y = "Articles", title = "A4h: International Relations") +
  ylim(0,9) +
  theme_light()
t8 <- ggplot(topicyear8, aes(x = Year, y = Articles)) + 
  geom_line() +  
  labs(x="Year", y = "Articles", title = "A4i: Political Violence") +
  ylim(0,9) +
  theme_light()
t9 <- ggplot(topicyear9, aes(x = Year, y = Articles)) + 
  geom_line() +  
  labs(x="Year", y = "Articles", title = "4b: Conflict") +
  ylim(0,9) +
  theme_light()
t10 <- ggplot(topicyear10, aes(x = Year, y = Articles)) + 
  geom_line() +  
  labs(x="Year", y = "Articles", title = "A4j: Identity") +
  ylim(0,9) +
  theme_light()
t11 <- ggplot(topicyear11, aes(x = Year, y = Articles)) + 
  geom_line() +  
  labs(x="Year", y = "Articles", title = "4d: Elections and Voting Behavior") +
  ylim(0,9) +
  theme_light()
t12 <- ggplot(topicyear12, aes(x = Year, y = Articles)) + 
  geom_line() +  
  labs(x="Year", y = "Articles", title = "A4k: Political Institutions") +
  ylim(0,9) +
  theme_light()

#Arrange indivdual plots into one figure and annotate
tlinetotal <- ggarrange(t3, t9, t1, t2, t11, t5, t6, t4, t7, t8, t10, t12,
                        common.legend = TRUE, legend = "none",
                        ncol = 2, nrow = 6)
annotate_figure(tlinetotal,
                top = text_grob("All Topics Over Time", color = "black", face = "bold", size = 14))

#Figures A5a-A5k: Disaggregated methods in MENA-focused scholarship in political science journals, 2000-2019
#Create subsets for each method using a dataset created in Excel using the Pivot Table function
methodyear1 <- subset(methodsovertime, Method == 1)
methodyear2 <- subset(methodsovertime, Method == 2)
methodyear3 <- subset(methodsovertime, Method == 3)
methodyear4 <- subset(methodsovertime, Method == 4)
methodyear5 <- subset(methodsovertime, Method == 5)
methodyear6 <- subset(methodsovertime, Method == 6)
methodyear7 <- subset(methodsovertime, Method == 7)
methodyear8 <- subset(methodsovertime, Method == 8)
methodyear9 <- subset(methodsovertime, Method == 9)
methodyear10 <- subset(methodsovertime, Method == 10)
methodyear11 <- subset(methodsovertime, Method == 11)

#Create indivdual plots for each method

m1 <- ggplot(methodyear1, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,8) +
  labs(x="Year", y = "Articles", title = "A5a: Experiments") +
  theme_light()
m2 <- ggplot(methodyear2, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,8) +
  labs(x="Year", y = "Articles", title = "A5b: Big Data") +
  theme_light()
m3 <- ggplot(methodyear3, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,8) +
  labs(x="Year", y = "Articles", title = "A5c: Large-n Cross-National") +
  theme_light()
m4 <- ggplot(methodyear4, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,8) +
  labs(x="Year", y = "Articles", title = "A5d: Large-n Sub-National") +
  theme_light()
m5 <- ggplot(methodyear5, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,8) +
  labs(x="Year", y = "Articles", title = "A5e: Single Case Study") +
  theme_light()
m6 <- ggplot(methodyear6, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,8) +
  labs(x="Year", y = "Articles", title = "A5f: Comparative Case Study (1-6 Cases)") +
  theme_light()
m7 <- ggplot(methodyear7, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,8) +
  labs(x="Year", y = "Articles", title = "A5g: Medium-n Case Study") +
  theme_light()
m8 <- ggplot(methodyear8, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,8) +
  labs(x="Year", y = "Articles", title = "A5h: Interviews") +
  theme_light()
m9 <- ggplot(methodyear9, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,8) +
  labs(x="Year", y = "Articles", title = "A5i: Ethnography") +
  theme_light()
m10 <- ggplot(methodyear10, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,8) +
  labs(x="Year", y = "Articles", title = "A5j: Content/Discourse Analysis") +
  theme_light()
m11 <- ggplot(methodyear11, aes(x = Year, y = Articles)) + 
  geom_line() +  
  ylim(0,8) +
  labs(x="Year", y = "Articles", title = "A5k: Formal Theory") +
  theme_light()

#Arrange indivdual plots into one figure and annotate
mlineall <- ggarrange(m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11,
                      common.legend = TRUE, legend = "none",
                      ncol = 2, nrow = 6)
annotate_figure(mlineall,
                top = text_grob("Methods Over Time", color = "black", face = "bold", size = 14))

